const { WeaSelect,WeaInputSearch,WeaNewScroll } = ecCom;
const { Col, Row, Spin } = antd;
const {inject, observer} = mobxReact;
const {toJS} = mobx;

@inject('listStore')
@observer
// 元素显示组件
class List extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      
    };
  }
  componentDidMount() {
  }
  linkFun=item=>{
    if(item.requestid > 0) {
      return <a className='truncate text-black ' target="_blank" href={"/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+item.requestid +"&f_weaver_belongto_userid="+item.randomField4}>{item.requestname}</a>
    }else {
      return <a className='truncate text-black ' target="_blank" href={item.tourl}>{item.requestname}</a>
  }}

  linkFun2=(item)=>{
    if(item.requestid > 0) {
      return window.open("/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+item.requestid +"&f_weaver_belongto_userid="+item.randomField4)
    }else {
      return window.open(item.tourl)
    }
  }





  render() {
    const { listStore } = this.props;
    const { datas,optionsValue,loading } = listStore;  
    return (
      <ul className='lists' >
        <Spin spinning={loading} tip="正在读取数据...">
        {
          datas.length>0 && datas.map((v,k)=>{
              return (
                <Row justify="space-between" align="middle" 
                className='py-2 pl-8 border-0 border-b border-gray-200 border-solid cursor-pointer'
                >
                  <Col span={10} className='truncate text-black' >
                    { 
                     // this.linkFun(v)
                      v.requestname
                    }
                    <p className='truncate text-blue-700'>{v.workflowidspan?v.workflowidspan:v.SysShortName}</p>
                  </Col>
                  <Col span={5} offset={2} style={{lineHeight:'38px'}}>
                    <p className='truncate'>
                      <font className='text-gray-600'>创建时间：</font>{v.createdate}</p>
                  </Col>
                  <Col span={5} offset={2} style={{lineHeight:'38px'}}>
                    <p  className='truncate'>
                      <font className='text-gray-600'>申请人：</font>
                      {v.createrspan? <span className='text-blue-700' dangerouslySetInnerHTML={{__html:v.createrspan}}></span>:
                       <span className='text-blue-700'>{v.lastname}</span>}
                       
                    </p>
                    <span className='operate' onClick={()=> {this.linkFun2(v)}}>操作</span>
                  </Col>
                </Row>
              )
          })
        }
        {
          datas.length==0?
            <div className='EmptyState'>
              <img src='${appRes}/iconEmptyState.png' />
              <span>暂无数据</span>
            </div>
          : null
        }
        </Spin>
      </ul>
    );    
  }
}

ecodeSDK.exp(List);
